package com.itcam.thread_;

/**
 * Author:Cammy.Wu
 * Date:2024-05-10
 * Description:
 */

public class ThreadMethodDemo06 {
    /*
        设置守护线程:

            public final void setDaemon(boolean on):设置守护线程
     */

    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);
                }
            }
        }, "线程A：");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 200; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);
                }
            }
        }, "线程B：");

        t2.setDaemon(true);

        t1.start();
        t2.start();
    }
}
